Prevent a crash in the TGA loader
authorMatthias Clasen <mclasen@redhat.com>
Tue, 23 Feb 2010 16:50:25 +0000 (11:50 -0500)
committerTristan Van Berkom <tristan.van.berkom@gmail.com>
Sun, 4 Apr 2010 00:56:21 +0000 (20:56 -0400)
Reported in bug 609744.

gdk-pixbuf/io-tga.c

index e42758c1980336d17cb13d7a8a1979c53f2adbf0..0391e1eec9df366c1343a8337dea772ceb5be065 100644 (file)
@@ -679,7 +679,13 @@ static gboolean try_colormap(TGAContext *ctx, GError **err)
        static guint n;
 
        g_return_val_if_fail(ctx != NULL, FALSE);
-       g_return_val_if_fail(ctx->cmap_size > 0, TRUE);
+
+        if (ctx->cmap_size == 0) {
+               g_set_error_literal(err, GDK_PIXBUF_ERROR,
+                                    GDK_PIXBUF_ERROR_CORRUPT_IMAGE,
+                                    _("Image is corrupted or truncated"));
+                       return FALSE;
+        }
 
        ctx->cmap = g_try_malloc(sizeof(TGAColormap));
        if (!ctx->cmap) {